Skip to main content
Version: Pro Edition for Eclipse Mosquitto 2.9

Mosquitto Metrics Exporter

Premium

Pro Edition for Eclipse Mosquitto provides a Prometheus exporter and a InfluxDB exporter which both expose the metrics available in the core broker and any metrics provided by other plugins.

Plugin configuration​

Prometheus Metrics Exporter​

To enable the Prometheus Metrics Exporter plugin it must be loaded into the broker with, by adding the following to your mosquitto.conf:

global_plugin /usr/lib/cedalo_metrics_prometheus.so

The plugin has some options which can be configured.

  • bind_address : by default, the exporter will listen on all available network interfaces. You can bind it to a specific address using this option. For example, plugin_opt_bind_address 192.0.2.1
  • port : by default, the exporter will listen on port 8000. You can use another port with this option. For example plugin_opt_port 8100
  • update_interval : metrics stored in the exporter are updated on a set interval, by default 15 seconds. It is important to match this to the scrape interval of your Prometheus setup. If you are using a 60 second scrape interval, then use plugin_opt_update_interval 60

A sample configuration could look like:

global_plugin /usr/lib/cedalo_metrics_prometheus.so
plugin_opt_update_interval 60
plugin_opt_bind_address 192.0.2.1
plugin_opt_port 8100

InfluxDB Metrics Exporter​

To enable the InfluxDB Metrics Exporter plugin it must be loaded into the broker with, by adding the following to your mosquitto.conf:

global_plugin /usr/lib/cedalo_metrics_influxdb.so

Connection and authentication​

The InfluxDB exporter can operate with InfluxDB servers 2.0 upwards and 1.x. These are configured differently to one another.

Influx 2.x​

To use InfluxDB 2.0 or above, you must configure a host, organization, bucket, and authentication token:

plugin_opt_host https://example.hoster.cloud2.influxdata.com
plugin_opt_organisation my-organisation
plugin_opt_bucket my-bucket
plugin_opt_token <token>

If you are using InfluxDB cloud, these values should all be easily discoverable. The plugin_opt_token option can contain either your literal authentication token, or the special value env. If set to env, the token will be read from the INFLUXDB_TOKEN environment variable instead.

Influx 1.6/8​

To use InfluxDB 1.8 or 1.6, you must configure at least a hostname and database:

global_plugin /usr/lib/cedalo_metrics_influxdb.so
plugin_opt_hostname influxdb.example.com
plugin_opt_database my-database
plugin_opt_port 8086
plugin_opt_use_tls true
Basic Authentication​

Basic HTTP authentication is supported for both connection modes by specifing a username and password:

...
plugin_opt_username my-username
plugin_opt_password my-password

Other options

plugin_opt_hostlabel - use a specific label for this host when sending data. If not specified, the local hostname will be used. plugin_opt_measurement - the measurement string to use when sending data. If not specified, mosquitto will be used. plugin_opt_cafile - a path to an x509 encoded certificate that should be trusted for making encrypted connections to the server. plugin_opt_update_interval - the interval between metrics submissions, in seconds.

A sample configuration could look like:

global_plugin /usr/lib/cedalo_metrics_influxdb.so
plugin_opt_update_interval 60
plugin_opt_hostname influxdb.example.com
plugin_opt_port 8100
plugin_opt_hostlabel broker1
plugin_opt_database edge_data
plugin_opt_use_tls true
plugin_opt_username username
plugin_opt_password password

Optional configuration (applies to both exporters)​

You may also consider turning off the $SYS updates from the broker:

sys_interval 0

Available metrics​

labelmetric typedescription
mosquitto_sessionsGaugeCurrent client sessions (includes offline clients)
mosquitto_clients_offlineGaugeCurrent offline client count
mosquitto_clients_onlineGaugeCurrent online client count
mosquitto_clients_expiredCounterTotal clients expired due to keepalive
mosquitto_subscriptionsGaugeCurrent subscription count
mosquitto_shared_subscriptionsGaugeCurrent shared subscription count
mosquitto_retained_messagesGaugeCurrent retained message count
mosquitto_bytes_receivedCounterTotal bytes received
mosquitto_bytes_sentCounterTotal bytes sent
mosquitto_pub_bytes_receivedCounterTotal PUBLISH payload bytes received
mosquitto_pub_bytes_sentCounterTotal PUBLISH payload bytes sent
mosquitto_message_store_countGaugeCurrent stored message count
mosquitto_message_store_bytesGaugeCurrent stored message bytes
mosquitto_out_packetsGaugeCurrent queued outgoing packet count (includes offline clients)
mosquitto_out_packet_bytesGaugeCurrent queued outgoing packet bytes (includes offline clients)
mosquitto_socket_connectionsCounterTotal incoming connections
mosquitto_mqtt_packets_receivedCounterTotal MQTT packets received
mosquitto_mqtt_packets_sentCounterTotal MQTT packets sent
mosquitto_mqtt_connect_receivedCounterMQTT CONNECT received
mosquitto_mqtt_connect_sentCounterMQTT CONNECT sent
mosquitto_mqtt_connack_receivedCounterMQTT CONNACK received
mosquitto_mqtt_connack_sentCounterMQTT CONNACK sent
mosquitto_mqtt_publish_droppedCounterMQTT PUBLISH dropped
mosquitto_mqtt_publish_receivedCounterMQTT PUBLISH received
mosquitto_mqtt_publish_sentCounterMQTT PUBLISH sent
mosquitto_mqtt_puback_receivedCounterMQTT PUBACK received
mosquitto_mqtt_puback_sentCounterMQTT PUBACK sent
mosquitto_mqtt_pubrec_receivedCounterMQTT PUBREC received
mosquitto_mqtt_pubrec_sentCounterMQTT PUBREC sent
mosquitto_mqtt_pubrel_receivedCounterMQTT PUBREL received
mosquitto_mqtt_pubrel_sentCounterMQTT PUBREL sent
mosquitto_mqtt_pubcomp_receivedCounterMQTT PUBCOMP received
mosquitto_mqtt_pubcomp_sentCounterMQTT PUBCOMP sent
mosquitto_mqtt_subscribe_receivedCounterMQTT SUBSCRIBE received
mosquitto_mqtt_subscribe_sentCounterMQTT SUBSCRIBE sent
mosquitto_mqtt_suback_receivedCounterMQTT SUBACK received
mosquitto_mqtt_suback_sentCounterMQTT SUBACK sent
mosquitto_mqtt_unsubscribe_receivedCounterMQTT UNSUBSCRIBE received
mosquitto_mqtt_unsubscribe_sentCounterMQTT UNSUBSCRIBE sent
mosquitto_mqtt_unsuback_receivedCounterMQTT UNSUBACK received
mosquitto_mqtt_unsuback_sentCounterMQTT UNSUBACK sent
mosquitto_mqtt_pingreq_receivedCounterMQTT PINGREQ received
mosquitto_mqtt_pingreq_sentCounterMQTT PINGREQ sent
mosquitto_mqtt_pingresp_receivedCounterMQTT PINGRESP received
mosquitto_mqtt_pingresp_sentCounterMQTT PINGRESP sent
mosquitto_mqtt_disconnect_receivedCounterMQTT DISCONNECT received
mosquitto_mqtt_disconnect_sentCounterMQTT DISCONNECT sent
mosquitto_mqtt_auth_receivedCounterMQTT AUTH received
mosquitto_mqtt_auth_sentCounterMQTT AUTH sent
mosquitto_basic_auth_successCounterSuccessful username/password authentication attempts
mosquitto_basic_auth_failCounterFailed username/password authentication attempts
mosquitto_basic_auth_errorCounterErrored username/password authentication attempts
mosquitto_extended_auth_successCounterSuccessful extended authentication attempts
mosquitto_extended_auth_failCounterFailed extended authentication attempts
mosquitto_extended_auth_errorCounterErrored extended authentication attempts
mosquitto_paged_client_messagesGaugeNumber of pending client messages paged to disk (since 2.9.1)

The broker process related metrics are exported by the Prometheus exporter only.

labelmetric typedescription
process_max_fdsGaugeMaximum number of allowed open file descriptors (including network sockets).
process_virtual_memory_max_bytesGaugeMaximum amount of virtual memory available in bytes
process_cpu_seconds_totalGaugeTotal user and system CPU time spent in seconds.
process_virtual_memory_bytesGaugeVirtual memory size in bytes.
process_resident_memory_bytesGaugeResident memory size in bytes.
process_start_time_secondsGaugeStart time of the process since unix epoch in seconds.
process_open_fdsGaugeNumber of open file descriptors (including network sockets).